Make deploy steps for an app all use the same commit#971
Open
Make deploy steps for an app all use the same commit#971
Conversation
When multiple commits hit a repo in quick succession each touching a
different app, it creates a race condition as each app CD action will
attempt to resolve the `HEAD` of `main`, not the ref that actually
triggered the workflow. So have `cd-{{app_name}}.yml` use the commit
that triggered the workflow (on `push` events) if `version` is not
provided explicitly (which will be the case for dispatch events).
That alone should fix the biggest issue, but while here ensure
`build-and-publish.yml` resolves the commit itself only once in the
`get-commit-hash` job, and then uses that everywhere else. This is so if
it is invoked manually or a deploy manually invoked non-commit ref, the
commit is fixed once the build starts at least.
doshitan
commented
Nov 3, 2025
| # Need to set a default value for when the workflow is triggered from a git push | ||
| # which bypasses the default configuration for inputs | ||
| run-name: Deploy ${{'{{'}}inputs.version || 'main' {{'}}'}} to {{ app_name }} ${{'{{'}} inputs.environment || 'dev' {{'}}'}} | ||
| run-name: Deploy ${{'{{'}} inputs.version || github.sha {{'}}'}} to {{ app_name }} ${{'{{'}} inputs.environment || 'dev' {{'}}'}} |
Contributor
Author
There was a problem hiding this comment.
Could potentially use github.ref here instead for a more skimmable name, but lean towards using what is ultimately the input.
sean-navapbc
reviewed
Nov 5, 2025
sean-navapbc
approved these changes
Nov 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When multiple commits hit a repo in quick succession each touching a different app, it creates a race condition as each app CD action will attempt to resolve the
HEADofmain, not the ref that actually triggered the workflow. So havecd-{{app_name}}.ymluse the commit that triggered the workflow (onpushevents) ifversionis not provided explicitly (which will be the case for dispatch events).That alone should fix the biggest issue, but while here ensure
build-and-publish.ymlresolves the commit itself only once in theget-commit-hashjob, and then uses that everywhere else. This is so if it is invoked manually or a deploy manually invoked with a non-commit ref, the commit is fixed once the build starts at least.Testing
platform-test branch: https://github.com/navapbc/platform-test/compare/doshitan/fix-cd-race-condition
Manual deploy: https://github.com/navapbc/platform-test/actions/runs/19047490583
Auto deploy: https://github.com/navapbc/platform-test/actions/runs/19047713627